package com.sjz.ctkj.canvasstudy.reciver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.sjz.ctkj.canvasstudy.MainActivity;
import com.sjz.ctkj.canvasstudy.SpaceFirstActivity;
import com.sjz.ctkj.canvasstudy.utils.ToastUtils;

public class OpenStartReceiver extends BroadcastReceiver{
    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
            Log.e("TAG", "onReceive: 开机启动");
            //开机启动
            Intent mainIntent = new Intent(context, SpaceFirstActivity.class);
            //在BroadcastReceiver中显示Activity，必须要设置FLAG_ACTIVITY_NEW_TASK标志
            mainIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(mainIntent);
        }
    }
}
